docs: add comprehensive code quality standards guide - #177
Conversation
Add CODE_QUALITY_README.md containing complete development standards: - Monster PR prevention strategies and enforcement - Fortress development workflow guidelines - Micro-PR discipline and size limits - Automated quality tooling documentation - Team adoption and success metrics Provides foundation for fortress-compliant development culture. Supports new developer onboarding and process standardization. Extracted from monster PR #171 as part of systematic decomposition. Tracked in issue #174. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Reviewer's GuideAdds a comprehensive CODE_QUALITY_README.md guide detailing fortress-compliant development culture by enforcing micro-PR discipline with hard limits, automated enforcement hooks, standardized workflow conventions, integrated quality tools, emergency override protocols, success metrics, and team adoption steps. Class diagram for code quality enforcement tools and scriptsclassDiagram
class PreCommitHook {
+validateBranchNaming()
+checkCommitMessageFormat()
+preventMixedConcerns()
}
class PRScopeChecker {
+validateFileCount()
+validateLineChanges()
+validateSinglePurpose()
+checkBranchNaming()
}
class GitHubActionsPRSizeGuard {
+runScopeValidation()
+failBuildOnLimitExceeded()
+preventMergeOnViolation()
}
class AutomatedQualityTool {
+runFormatting()
+runLinting()
+runTypeChecking()
+runSecurityScan()
+runDependencyCheck()
}
PreCommitHook --> PRScopeChecker
PRScopeChecker --> GitHubActionsPRSizeGuard
GitHubActionsPRSizeGuard --> AutomatedQualityTool
Flow diagram for emergency override protocolflowchart TD
A["PR exceeds limits"] --> B["Developer applies EMERGENCY-OVERRIDE label"]
B --> C["Requires 2 approvers"]
C --> D["PR auto-closes after 8h"]
C --> E["Max 1 override per week"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds two documentation files: a CODE_QUALITY_README.md that codifies code-quality standards, PR/branch/commit conventions, enforcement mechanisms and adoption steps; and a .gitmessage.txt commit-template with commit-format rules and examples. No code or public APIs changed. Changes
Sequence Diagram(s)(omitted — changes are documentation-only and do not modify runtime control flow) Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @uelkerd, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a comprehensive Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Here's the code health analysis summary for commits Analysis Summary
|
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a comprehensive code quality standards guide focused on preventing large, unwieldy pull requests and establishing a disciplined development culture. The guide establishes strict limits and automated enforcement mechanisms to maintain small, focused PRs.
Key Changes:
- Establishes hard limits for PR size (≤50 files, ≤1500 lines) with automated enforcement
- Documents comprehensive development workflow including branch naming, commit formats, and quality tools
- Provides implementation strategy for team adoption and success metrics tracking
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| ### **2. PR Scope Checker** | ||
| ```bash | ||
| python scripts/check_pr_scope.py --strict | ||
| ``` |
There was a problem hiding this comment.
The script scripts/check_pr_scope.py is referenced but there's no indication whether this script exists in the repository. Consider adding a note about script availability or implementation status.
| ``` |
Note: The script
scripts/check_pr_scope.pyis currently under development and may not be available in this repository yet.
|
|
||
| ### **Immediate Actions** | ||
| 1. **Install pre-commit hooks**: `pre-commit install` | ||
| 2. **Set commit template**: `git config commit.template .gitmessage.txt` |
There was a problem hiding this comment.
References .gitmessage.txt file but doesn't indicate if this file exists in the repository or needs to be created. Consider clarifying the file's availability or providing its contents.
| 2. **Set commit template**: `git config commit.template .gitmessage.txt` | |
| 2. **Set commit template**: `git config commit.template .gitmessage.txt` | |
| > **Note:** If `.gitmessage.txt` does not exist in your repository root, create it with the following recommended contents: | |
| ```txt | |
| # Commit message template | |
| # <type>(<scope>): <short summary> | |
| # | |
| # Example: | |
| # feat(api): add user authentication endpoint | |
| # | |
| # - Use imperative mood ("add", not "added"/"adds") | |
| # - Keep summary under 72 characters | |
| # - Reference issues if applicable (e.g., "Fixes #123") | |
| # | |
| # Body (optional): Explain what and why, not how. | |
| # | |
| # Footer (optional): Breaking changes, issues closed, etc. |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive code quality guide, CODE_QUALITY_README.md, which establishes strict rules for development to prevent large, unmanageable pull requests. The guide is well-structured and covers hard limits, development workflows, tooling, and enforcement strategies. My review focuses on improving clarity, consistency with existing project tooling, and adjusting some rules that might be overly restrictive. Key suggestions include updating the list of code quality tools to mention ruff, correcting an inconsistency in a branch naming example, and reconsidering the very strict limits on branch lifetime and PR description length.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (9)
CODE_QUALITY_README.md (9)
25-26: Avoid “FORCE merge” language; reflect what’s implementable.Auto-closing or flagging stale PRs is feasible; forcing merges is not. Suggest softening the comment.
Apply:
-branch_lifetime: 48h # FORCE merge or close after 48h +branch_lifetime: 48h # Auto-close or require split after 48h (no force-merge)
37-43: Pre-commit hook wording is misleading; use the pre-commit framework and commit-msg for messages..git/hooks isn’t versioned; branch naming can’t be reliably enforced locally. Recommend documenting pre-commit + commit-msg hooks and move branch naming checks to CI.
Apply:
-### **1. Pre-Commit Hook** -The `.git/hooks/pre-commit` script automatically: -- Validates branch naming (`feat/add-auth`, `fix/memory-leak`) -- Checks commit message format (`feat: add user auth`) -- Prevents commits with mixed concerns -- Runs before every commit +### **1. Local Hooks (pre-commit + commit-msg)** +Use the pre-commit framework (versioned via `.pre-commit-config.yaml`) to run format/lint/type/security checks on staged files. Enforce commit message format via a `commit-msg` hook (e.g., Commitizen). +Notes: +- Branch naming and “single purpose” are enforced in CI (see PR Scope Checker), not locally. +- Hooks run automatically once installed (`pre-commit install` and `pre-commit install --hook-type commit-msg`).
62-72: This isn’t bash; fix the fence language.Use “md” or “text” to avoid confusing syntax highlighters.
-```bash +```md # Answer these questions: 1. Can I describe this in ONE sentence? 2. Will this affect < 50 files? 3. Can I complete this in < 4 hours? 4. Is this EXACTLY ONE concern? 5. Am I mixing API + tests + docs? # If ANY answer is NO: Split into separate PRs
75-82: Add a language to fenced code block (markdownlint MD040).-``` +```text feat/short-description # New features fix/short-description # Bug fixes chore/short-description # Build/tooling changes refactor/short-description # Code restructuring docs/short-description # Documentation test/short-description # Test additions
93-97: Add fence language (MD040) and reflect git commit syntax.-``` +```gitcommit <type>(<scope>): <subject> <body - optional>
99-104: Add fence language (MD040) for commit examples.-``` +```gitcommit feat: add JWT token authentication fix: resolve memory leak in model loading chore: update Python dependencies refactor: simplify rate limiter logic
189-197: Add fence language (MD040) for the PR comment template.-``` +```md 🚨 **SCOPE VIOLATION DETECTED** This PR exceeds our size limits: - Files: [count]/50 max - Lines: [count]/1500 max - Multiple concerns: [list them] Please split into focused micro-PRs.
29-34: Fix “emphasis as heading” (MD036) and improve scannability.-**EVERY PR MUST HAVE EXACTLY ONE SENTENCE DESCRIBING ITS PURPOSE** +#### Requirement: PR purpose must be exactly one sentence @@ -**Small PRs = Fast reviews = Quick merges = Happy developers = Successful project** +### Summary +Small PRs = Fast reviews = Quick merges = Happy developers = Successful projectAlso applies to: 203-206
132-140: Clarify override mechanics.GitHub cannot bypass required checks by workflow alone. Suggest noting that overrides rely on: label + 2 approvers + admin “bypass PR requirements” permission, or a temporary policy change.
I can draft pr-override.yml and an “Override Playbook” section if you want it in a follow-up PR.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
CODE_QUALITY_README.md(1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
CODE_QUALITY_README.md
29-29: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
75-75: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
93-93: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
99-99: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
189-189: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
203-203: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Sourcery review
🔇 Additional comments (2)
CODE_QUALITY_README.md (2)
1-8: Solid addition; policy is clear and aligns with the repo’s fortress goals.Well-scoped, doc‑only PR; easy to adopt.
21-26: Enforcement artifacts verified — action: confirm branch-protection
Found: scripts/check_pr_scope.py (present); .github/workflows/pr-scope-check.yml runs on pull_request and invokespython scripts/check_pr_scope.py --strictwithcontinue-on-error: false(job fails on violations); Makefile definesformat,lint,test,quality-checktargets;.pre-commit-config.yamlcontains fortress-guard plus ruff/mypy/bandit hooks. Ensure this workflow is configured as a required status check in branch protection to actually block merges (branch-protection not validated here).
- Update tooling list to reflect current ruff usage (replaces Black, isort, flake8) - Extend branch lifetime from 48h to 72h with extension clarification - Fix pre-commit framework reference to use .pre-commit-config.yaml - Correct branch naming example from 'feature' to 'feat' for consistency - Clarify PR description rule to encourage detailed body descriptions - Improve accuracy and reduce confusion for developers
- Add note confirming PR scope checker script availability - Clarify that .gitmessage.txt is included in repository - Restore comprehensive .gitmessage.txt template with Conventional Commits - Address Copilot AI feedback about missing file references - Ensure all referenced files are available and documented
- Soften 'FORCE merge' language to 'Auto-close or require split' - Fix pre-commit hook wording to reflect framework usage - Correct fence language from bash to md/text/gitcommit - Add proper language tags for all code blocks (MD040) - Fix emphasis as heading (MD036) for better scannability - Clarify override mechanics with GitHub permissions note - Improve documentation accuracy and markdown compliance - Address all linting and formatting issues
🎯 Purpose
Add comprehensive code quality standards documentation to establish fortress-compliant development culture.
📋 Changes
🏰 Fortress Compliance
✅ Files: 1/5 (maximum compliance)
✅ Purpose: Single concern (documentation only)
✅ Scope: Team process standardization
✅ Branch: From main (fortress-compliant)
✅ Size: Single comprehensive guide
🔄 Extraction Details
🧪 Testing
📊 Impact
🎯 Key Features
Phase 2 Progress: 2/4 documentation extractions complete
🤖 Generated with Claude Code
Summary by Sourcery
Add CODE_QUALITY_README.md with a comprehensive code quality standards guide to enforce micro-PR discipline, automated enforcement, development workflows, tooling, metrics, and team adoption protocols
Documentation:
Summary by CodeRabbit